/*
 * Copyright (C), 2005-2018, 上海瑛麒动漫科技有限公司
 * FileName: RedissonList.java
 * Author:   tianmu
 * Date:     2018年2月22日 下午5:31:57
 * Description: //模块目的、功能描述
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.sfang.common.redis.redisson;

import com.sfang.common.redis.sdk.RedisList;
import org.redisson.api.RList;
import org.redisson.api.RedissonClient;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 *
 * @author tianmu
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class RedissonList<V> implements RedisList<V> {

    private final RList<V> rList;

    public RedissonList(RedissonClient redissonClient, String key) {
        rList = redissonClient.getList(key);
    }

    @Override
    public boolean add(V e) {
        return rList.add(e);
    }

    @Override
    public boolean addAll(Collection<V> c) {
        return rList.addAll(c);
    }

    @Override
    public boolean contains(V o) {
        return rList.contains(o);
    }

    @Override
    public boolean delete() {
        return rList.delete();
    }

    @Override
    public boolean expire(long timeToLive, TimeUnit timeUnit) {
        return rList.expire(timeToLive, timeUnit);
    }

    @Override
    public boolean expireAt(long timestamp) {
        return rList.expireAt(timestamp);
    }

    @Override
    public V get(int index) {
        return rList.get(index);
    }

    @Override
    public List<V> get(int... indexes) {
        return rList.get(indexes);
    }

    @Override
    public boolean isEmpty() {
        return rList.isEmpty();
    }

    @Override
    public boolean isExists() {
        return rList.isExists();
    }

    @Override
    public List<V> readAll() {
        return rList.readAll();
    }

    @Override
    public V set(int index, V element) {
        return rList.set(index, element);
    }

    @Override
    public int size() {
        return rList.size();
    }

    @Override
    public V rightPop() {
        return rList.remove(0);
    }

}
